
package org.springblade.modules.videoanswer.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.videoanswer.entity.Fans;
import org.springblade.modules.videoanswer.vo.FansVO;
import org.springblade.modules.videoanswer.service.IFansService;
import org.springblade.core.boot.ctrl.BladeController;

/**
 * 公众号粉丝表 控制器
 *
 * @author jiangyandong
 * @since 2021-03-19
 */
@RestController
@AllArgsConstructor
@RequestMapping("/videoanswer/fans")
@Api(value = "公众号粉丝表", tags = "公众号粉丝表接口")
public class FansController extends BladeController {

	private IFansService fansService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入fans")
	public R<Fans> detail(Fans fans) {
		Fans detail = fansService.getOne(Condition.getQueryWrapper(fans));
		return R.data(detail);
	}

	/**
	 * 分页 公众号粉丝表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入fans")
	public R<IPage<Fans>> list(Fans fans, Query query) {
		IPage<Fans> pages = fansService.page(Condition.getPage(query), Condition.getQueryWrapper(fans));
		return R.data(pages);
	}

	/**
	 * 自定义分页 公众号粉丝表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入fans")
	public R<IPage<FansVO>> page(FansVO fans, Query query) {
		IPage<FansVO> pages = fansService.selectFansPage(Condition.getPage(query), fans);
		return R.data(pages);
	}

	/**
	 * 新增 公众号粉丝表
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入fans")
	public R save(@Valid @RequestBody Fans fans) {
		return R.status(fansService.save(fans));
	}

	/**
	 * 修改 公众号粉丝表
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入fans")
	public R update(@Valid @RequestBody Fans fans) {
		return R.status(fansService.updateById(fans));
	}

	/**
	 * 新增或修改 公众号粉丝表
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入fans")
	public R submit(@Valid @RequestBody Fans fans) {
		return R.status(fansService.saveOrUpdate(fans));
	}

	
	/**
	 * 删除 公众号粉丝表
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(fansService.removeByIds(Func.toIntList(ids)));
	}

	
}
